﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using GrainManage.Data.Model.Table;
using GrainManage.Data.Model;

namespace GrainManage.Data.Service
{
    public class CommonService : BaseService
    {
        public CommonService(GrainManage.Data.Access.AccessBase proc) : base(proc) { }

        public List<string> GetSpecifiedColumn(string table, string column, IPageable page, string creator)
        {
            var fieldList = new List<string>();

            #region Read DataSet
            DataSet type = Proc.ExecuteQuery(ProcConst.Common_GetByTableColumnExtent, table, column, page.PageIndex, page.PageSize, creator);
            foreach (DataRow item in type.Tables[0].Rows)
            {
                if (item[0] != DBNull.Value)
                {
                    fieldList.Add(item[0] as string);
                }
            }
            #endregion

            return fieldList;
        }

        public List<string> GetTypeName(TypeFlag typeFlag, IPageable page)
        {
            var fieldList = new List<string>();
            DataSet type = Proc.ExecuteQuery(ProcConst.Type_GetNameByFlag, (int)typeFlag, page.PageIndex, page.PageSize);
            foreach (DataRow item in type.Tables[0].Rows)
            {
                if (item[0] != DBNull.Value)
                {
                    fieldList.Add(item[0] as string);
                }
            }

            return fieldList;
        }
    }
}
